home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / setnrams.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  2.2 KB  |  84 lines

  1. #include "bbs.h"
  2. #define StripInfo(x,y) x=strlen(y)-1; while(x>-1) { if(y[x]=='.') { y[x]='\0'; break; } x--; }
  3.  
  4. void SetNRAMS(void)
  5. {
  6.    struct DiskObject *dobj;
  7.    char **oldtooltypes;
  8.    char *s;
  9.    char temp[200];
  10.    char FileName[200];
  11.    int j;
  12.    sprintf(temp,"%sNode%d/NRAMS",Cmds->BBSLoc,Cmds->AcLvl[LVL_NODE_NUMBER]);
  13.    if(GetFirstName(temp,FileName))
  14.    {
  15.       if(SEROUT)
  16.       {
  17.         StripInfo(j,FileName);
  18.         sprintf(temp,"%sNode%d/NRAMS/%s",Cmds->BBSLoc,Cmds->AcLvl[LVL_NODE_NUMBER],FileName);
  19.         IO_Flags[IOFLAG_SER_IN]=1;
  20.                  IO_Flags[IOFLAG_SER_OUT]=0;
  21.                  IO_Flags[IOFLAG_SCR_OUT]=0;
  22.                  IO_Flags[IOFLAG_KBD_IN]=1;
  23.         DropDTR();
  24.         IntDoReset(Sopt->OffHook);
  25.         SetEnvMsg("Setting NRAMS");
  26.         dobj=GetDiskObject(temp);
  27.         if(dobj)
  28.         {
  29.            oldtooltypes=dobj->do_ToolTypes;
  30.            j=1;
  31.            sprintf(FileName,"NRAM.%d",j++);
  32.            while(s=FindToolType(oldtooltypes,FileName))
  33.            {
  34.               sprintf(FileName,"Setting NRAM.%d",j-1);
  35.               SetEnvMsg(FileName);
  36.               IntDoReset(s); Delay(60L);
  37.               sprintf(FileName,"NRAM.%d",j++);
  38.            }
  39.            Reset_System(0);
  40.            SetEnvStat(ENV_AWAITCONNECT);
  41.            FreeDiskObject(dobj);
  42.         }
  43.       }
  44.     }
  45.     else
  46.     {
  47.        SetEnvMsg("NO NRAM.DEF");
  48.        Delay(30L);
  49.        SetEnvStat(ENV_AWAITCONNECT);
  50.     }
  51. }
  52. int GetFirstName(char *path,char *buf)
  53. {
  54.    struct FileLock      *pdir = NULL;
  55.    struct FileInfoBlock *dir_info = NULL;
  56.    int returnval=0;
  57.    if ((dir_info =(struct FileInfoBlock *)AllocDosObject(DOS_FIB,NULL)) == NULL)
  58.    {
  59.      Delay(300L);
  60.      return(0);
  61.    }
  62.   if (! (pdir=(struct FileLock *)Lock(path,(ULONG)ACCESS_READ)) )
  63.   {
  64.        UnLock((BPTR)pdir);
  65.        FreeDosObject(DOS_FIB,dir_info);
  66.        return(0);
  67.   }
  68.   if ( ! Examine((BPTR)pdir, dir_info) )
  69.   {
  70.     UnLock((BPTR)pdir);
  71.     FreeDosObject(DOS_FIB,dir_info);
  72.     return(0);
  73.   }
  74.   if(ExNext((BPTR)pdir,dir_info))
  75.   {
  76.     if(dir_info->fib_DirEntryType < 0L )
  77.     {
  78.         returnval=1; strcpy(buf,dir_info->fib_FileName);
  79.     }
  80.   }
  81.    UnLock((BPTR)pdir);
  82.    FreeDosObject(DOS_FIB,dir_info);
  83.   return(returnval);
  84. }